<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	session.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="${basePath }">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<title>西普茗茶商品-商品详情</title>
<meta name="renderer" content="webkit">

<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="https://cdn.bootcss.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link href="https://cdn.bootcss.com/Swiper/3.0.8/css/swiper.min.css" rel="stylesheet" type="text/css" />
<!-- END PAGE LEVEL STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="assets/css/style-metronic.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style-responsive.css" rel="stylesheet" type="text/css" />
<link href="assets/css/themes/light.css" rel="stylesheet" type="text/css" id="style_color" />
<link href="assets/css/custom.css" rel="stylesheet" type="text/css" />
<link href="assets/css/pages/blog.css" rel="stylesheet" type="text/css" />
<link href="css/iconfont.css" rel="stylesheet" type="text/css" />
<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico" />

<script type="text/javascript">
	var isHTML5 = true;
</script>
<!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
	<script src="js/excanvas.min.js"></script> 
    <script type="text/javascript">
		isHTML5 = false;
	</script>
<![endif]-->

<style type="text/css">
.swiper-container {
	width: 100%;
	height: 250px;
	margin: 10px auto;
}

.swiper-slide {
	font-size: 18px;
	background: transparent;
	width: 250px;
	/* Center slide text vertically */
	display: -webkit-box;
	display: -ms-flexbox;
	display: -webkit-flex;
	display: flex;
	-webkit-box-pack: center;
	-ms-flex-pack: center;
	-webkit-justify-content: center;
	justify-content: center;
	-webkit-box-align: center;
	-ms-flex-align: center;
	-webkit-align-items: center;
	align-items: center;
	text-align: center;
}

.swiper-slide img {
	border-radius: 10px !important;
}

#goodsDetail_div img {
	display: block;
	max-width: 100%;
	height: auto;
	display: block;
	margin-left: auto;
	margin-right: auto;
	margin-left: auto;
}

body {
	background: #f6e7c6 !important;
}
</style>
</head>
<!--/head-->
<!-- BEGIN BODY -->
<body class="page-footer-fixed">
	<!-- BEGIN HEADER -->
	<div class="header navbar">
		<div class="container-fluid">
			<div class="row">
				<div class="col-xs-2 text-center">
					<a href="./" class="icon_a_link">
						<!-- <i class="fa fa-home text-gold" style="font-size: 24px; line-height: 40px; height: 40px;"></i> -->
						<i style="font-size: 24px; line-height: 40px; height: 40px;" class="iconfont icon-qh-home text-gold">&#xe61a;</i>
					</a>
				</div>
				<div class="col-xs-8 text-center">
					<h4>商品详情</h4>
				</div>
				<div class="col-xs-2 text-center">
					<a href="item/infocenter.jsp" class="icon_a_link">
						<!-- <i class="fa fa-user text-gold" style="font-size: 24px; line-height: 40px; height: 40px;"></i> -->
						<i style="font-size: 24px; line-height: 40px; height: 40px;" class="iconfont text-gold icon-qh-infocenter">&#xe61d;</i>
					</a>
				</div>
			</div>
		</div>
	</div>
	<!-- END HEADER -->
	<div class="clearfix "></div>
	<c:set value="${ fn:split(goods.goodsGallery, ',') }" var="goodsGalleryList" />
	<!-- BEGIN CONTAINER -->
	<div class="page-container">

		<!-- 首页banner开始 -->
		<div class="swiper-container" id="goods_gallery_swiper_div">
			<div class="swiper-wrapper" id="goods_pic_div">
				<c:forEach items="${goodsGalleryList }" var="gg">
					<div class="swiper-slide">
						<img class="center-block swiper-lazy" data-src="${gg }" data-real-src="${gg }" height="250" style="border-radius: 10px !important;">
						<!-- Preloader image -->
						<div class="swiper-lazy-preloader swiper-lazy-preloader-black"></div>
					</div>
				</c:forEach>
			</div>
			<!-- Add Pagination -->
			<div class="swiper-pagination"></div>
		</div>
		<!-- 首页banner结束 -->

		<!-- BEGIN CONTENT -->
		<div class="page-content-wrapper">
			<div class="page-content no-space" style="margin-bottom: 50px !important; background: transparent !important;">
				<!-- BEGIN CONTENT -->
				<div class="container padding-top-10 padding-bottom-10 bg-white" style="border-top: 1px solid #ccc; border-bottom: 1px solid #ccc;">
					<div class="caption">
						<div class="row margin-top-5 margin-bottom-5 margin-left-5 margin-right-5">
							<div class="col-xs-12 text-left">
								<h4>${goods.goodsName }</h4>
								<p class="text-red">${goods.goodsTips }</p>
							</div>
						</div>
						<div class="row margin-top-10 margin-bottom-10 margin-left-5 margin-right-5">
							<div class="col-xs-8 text-left">
								<span class="black">价格：</span>
								<c:if test="${goods.goodsOriginalPrice!=null }">
									<del class="margin-right-5">
										<span class="text-light"><i class="fa fa-rmb"></i> <fmt:formatNumber value="${goods.goodsOriginalPrice}" type="currency" pattern="#,##0.##" /></span>
									</del>
								</c:if>
								<span class="text-red"><strong><i class="fa fa-rmb"></i> <fmt:formatNumber value="${goods.goodsPrice }" type="currency" pattern="#,##0.##" /></strong></span>
							</div>
							<div class="col-xs-4 text-right">
								<span class="text-light">销售${goods.goodsSalesNumber==null?0:goods.goodsSalesNumber }件</span>
							</div>
						</div>
						<c:if test="${goods.goodsDiscount!=null }">
							<div class="row margin-top-10 margin-bottom-10 margin-left-5 margin-right-5">
								<div class="col-xs-12 text-left">
									<span class="black">优惠：</span> <span class="label label-sm label-danger"><fmt:formatNumber value="${goods.goodsDiscount*10 }" pattern="#,##0.##" />折</span>
								</div>
							</div>
						</c:if>
					</div>
				</div>
				<!-- END CONTENT -->

				<div class="container margin-top-10 padding-top-10 padding-bottom-10 bg-white" style="border-top: 1px solid #ccc; border-bottom: 1px solid #ccc;">
					<div class="">
						<div class="row margin-left-5 margin-right-5">
							<div class="col-xs-3 margin-top-8">
								<i style="font-size: 18px;" class="iconfont icon-qh-number text-gold">&#xe629;</i> 数量：
							</div>
							<div class="col-xs-5">
								<div class="input-group">
									<span class="input-group-btn">
										<button class="btn default number_minus_button" type="button" data-target="#buy_number">-</button>
									</span>
									<input type="text" class="form-control text-center buy_number_input" value="${goods.goodsMinBuyNumber!=null?goods.goodsMinBuyNumber:1 }" id="buy_number"
										data-minnumber="${goods.goodsMinBuyNumber!=null?goods.goodsMinBuyNumber:1 }" data-maxnumber="${goods.goodsInventoryNumber }">
									<span class="input-group-btn">
										<button class="btn default number_add_button" type="button" data-target="#buy_number">+</button>
									</span>
								</div>
							</div>
							<div class="col-xs-4 margin-top-8">
								库存<span class="text-red">${goods.goodsInventoryNumber }</span>件
								<c:if test="${goods.goodsMinBuyNumber!=null}">，最少购买${goods.goodsMinBuyNumber}件</c:if>
							</div>
						</div>
					</div>
				</div>

				<div id="go_to_goods_detail_div" class="container margin-top-10 padding-top-10 padding-bottom-10 bg-white" style="border-top: 1px solid #ccc; border-bottom: 1px solid #ccc;">

					<div class="row margin-top-10 margin-bottom-10 margin-left-5 margin-right-5">
						<div class="col-xs-12 text-left">
							<i class="fa fa-list-alt text-gold text-big"></i> 图文详情 <i style="font-size: 30px;" class="fa fa-angle-right pull-right text-gold"></i>
						</div>
					</div>
				</div>
				<c:if test="${commentList!=null&&fn:length(commentList)>0 }">
					<div class="container margin-top-10 padding-top-10 padding-bottom-10 bg-white" style="border-top: 1px solid #ccc; border-bottom: 1px solid #ccc;">
						<div class="row margin-top-10 margin-bottom-10 margin-left-5 margin-right-5 padding-bottom-15" style="border-bottom: 1px solid #ccc;">
							<div class="col-xs-6">
								<i class="fa fa-comments-o text-gold"></i> 评价 <small class="margin-left-10"><span class="text-red"> 好评 <strong>95%</strong>
								</span></small>
							</div>
							<div class="col-xs-6 text-right">
								<small class="margin-right-5"><span> 共 ${goods.goodsCommentNumber==null?0:goods.goodsCommentNumber } 条评价 </span></small> <i style="font-size: 30px;" class="fa fa-angle-right text-gold pull-right"></i>
							</div>
						</div>
						<div class="blog-page">
							<c:forEach items="${ commentList}" var="co" varStatus="coStat">
								<div class="container">
									<div class="media padding-top-20">
										<div class="media-body">
											<h5 class="media-heading">
												<span>***${fn:substring(co.buyerId, 20, 25)}</span> <span> <c:forEach begin="1" end="${co.commentDescriptionStar }">
														<i class="fa fa-star text-green"></i>
													</c:forEach> <c:forEach begin="${co.commentDescriptionStar+1 }" end="5">
														<i class="fa fa-star-o text-light"></i>
													</c:forEach>
												</span> <span class="post-time"> <fmt:formatDate value="${co.commentContentTime }" pattern="yyyy-MM-dd" />
												</span>
											</h5>
											<p>${co.commentContent }</p>
											<p></p>
											<div class="clearfix"></div>
											<c:if test="${co.commentReply!=null&&co.commentReply!='' }">
												<hr>
												<!-- Nested media object -->
												<div class="media">
													<a href="javascript:void(0)" class="pull-left">
														<img alt="" src="images/buyer_default_head_img.jpg" class="media-object">
													</a>
													<div class="media-body text-red">
														<h5 class="media-heading">
															<span>客服人员</span> <span> </span> <span class="post-time"> <fmt:formatDate value="${co.commentReplyTime }" pattern="yyyy-MM-dd" />
															</span>
														</h5>
														<p>${co.commentReply }</p>
													</div>
												</div>
												<!--end media-->
											</c:if>
										</div>
									</div>
								</div>
								<div class="clearfix"></div>
								<hr>
							</c:forEach>
						</div>
						<div class="container text-center" style="margin-top: -25px;">
							<a href="show_goods_comment_list?id=${goods.goodsId }" class="btn center-block text-gold" style="border-radius: 5px !important; display: inline-block; border: 1px solid #cea047;"> 查看全部评价 </a>
						</div>
					</div>
				</c:if>
				<c:if test="${buyerMessageList!=null&&fn:length(buyerMessageList)>0 }">

					<div class="container margin-top-10 padding-top-10 padding-bottom-10 bg-white" style="border-top: 1px solid #ccc; border-bottom: 1px solid #ccc;">
						<div class="row margin-top-10 margin-bottom-10 margin-left-5 margin-right-5 padding-bottom-15" style="border-bottom: 1px solid #ccc;">
							<div class="col-xs-6">
								<i class="fa fa-comments-o text-gold"></i> 留言 </span></small>
							</div>
							<div class="col-xs-6 text-right">
								<i style="font-size: 30px;" class="fa fa-angle-right text-gold pull-right"></i>
							</div>
						</div>
						<div class="blog-page">

							<c:forEach items="${ buyerMessageList}" var="co" varStatus="coStat">
								<div class="container">
									<div class="media padding-top-20">
										<div class="media-body">
											<h5 class="media-heading">
												<span>***${fn:substring(co.buyerId, 20, 25)}</span><span class="post-time"> <fmt:formatDate value="${co.buyerMessageTime }" pattern="yyyy-MM-dd" />
												</span>
											</h5>
											<p>${co.buyerMessageContent }</p>
											<div class="clearfix"></div>
											<hr>
											<!-- Nested media object -->
											<div class="media">
												<a href="javascript:void(0)" class="pull-left">
													<img alt="" src="images/buyer_default_head_img.jpg" class="media-object">
												</a>
												<div class="media-body text-red">
													<h5 class="media-heading">
														<span>客服人员</span> <span> </span> <span class="post-time"> <fmt:formatDate value="${co.buyerMessageReplyTime }" pattern="yyyy-MM-dd" />
														</span>
													</h5>
													<p>${co.buyerMessageReply }</p>
												</div>
											</div>
											<!--end media-->
										</div>
									</div>
								</div>
								<div class="clearfix"></div>
								<hr>
							</c:forEach>
						</div>

						<div class="container text-center" style="margin-top: -25px;">
							<a href="show_goods_message_list?id=${goods.goodsId }" class="btn center-block text-gold" style="border-radius: 5px !important; display: inline-block; border: 1px solid #cea047;"> 查看全部留言 </a>
						</div>
					</div>

				</c:if>

				<div id="go_to_post_message_div" class="container margin-top-10 padding-top-10 padding-bottom-10 bg-white" style="border-top: 1px solid #ccc; border-bottom: 1px solid #ccc;">
					<div class="row margin-top-10 margin-bottom-10 margin-left-5 margin-right-5">
						<div class="col-xs-12 text-left">
							<i class="fa fa-comment-o text-gold text-big"></i> 发表留言 <i style="font-size: 30px;" class="fa fa-angle-right pull-right text-gold"></i>
						</div>
					</div>
				</div>

				<div class="container text-center"></div>

				<div id="goods_detail_big_div">
					<div class="tabbable-custom nav-justified margin-top-20">
						<ul class="nav nav-tabs nav-justified center-block margin-bottom-15" style="border: 1px solid #ccc; background: white; border-radius: 5px !important; width: 90% !important; margin: 0px auto;">
							<li class="active">
								<a href="#goodsDetail_div" data-toggle="tab"> 商品介绍 </a>
							</li>
							<li>
								<a href="#tab_1_1_2" data-toggle="tab"> 售后保障 </a>
							</li>
						</ul>
						<div id="need_lazy_img_div" class="tab-content">
							<div class="tab-pane active text-center" id="goodsDetail_div">${fn:replace(goods.goodsDetail, 'src=', 'data-original=')}</div>
							<div class="tab-pane" id="tab_1_1_2">
								<h4>服务承诺：</h4>
								<p>平台销售并发货的商品，由平台提供发票和相应的售后服务。请您放心购买！ 注：因厂家会在没有任何提前通知的情况下更改产品包装、产地或者一些附件，本司不能确保客户收到的货物与商城图片、产地、附件说明完全一致。只能确保为原厂正货！并且保证与当时市场上同样主流新品一致。若本商城没有及时更新，请大家谅解！</p>
							</div>
						</div>
						<script type="text/javascript">
							var need_lazy_img_div = document.getElementById("need_lazy_img_div");
							var img_arr = need_lazy_img_div.getElementsByTagName("img");
							for (var i = 0; i < img_arr.length; i++)
							{
								//img_arr[i].setAttribute("data-original", img_arr[i].src);
								img_arr[i].src = "images/default_light_goods_pic.jpg";
								img_arr[i].setAttribute("class", "lazy img-responsive lazy_load_img " + img_arr[i].getAttribute("class"));
							}
						</script>
					</div>
				</div>
			</div>
		</div>
		<!-- END CONTAINER -->
	</div>
	<!-- BEGIN FOOTER -->
	<div class="footer">
		<div class="container">
			<div class="row">
				<div class="col-xs-2 text-center" id="buyer_collection_button_div">
					<c:if test="${goodsIsCollected==true }">
						<a href="javascript:void(0)" class="icon-btn cancel_goods_collection">
							<i class="fa fa-star text-gold"></i>
							<div class="text-gold">已收藏</div>
						</a>
					</c:if>
					<c:if test="${goodsIsCollected==false }">
						<a href="javascript:void(0)" class="icon-btn add_goods_collection">
							<i class="fa fa-star-o text-gold"></i>
							<div class="text-gold">收藏</div>
						</a>
					</c:if>
				</div>
				<div class="col-xs-4 text-center">
					<button class="btn btn-block add_to_shopping_cart_button text-white" style="background: #c48e36; border-radius: 5px !important;" data-id="${goods.goodsId }">加入购物车</button>
				</div>
				<div class="col-xs-4 text-center">
					<button class="btn btn-block buy_right_now_button text-white" style="background: #a80e28; border-radius: 5px !important;" data-id="${goods.goodsId }">立即购买</button>
				</div>
				<div class="col-xs-2 text-center">
					<a href="cart" class="icon-btn">
						<!-- <i class="fa fa-shopping-cart text-gold" id="shooping_cart_icon"></i> -->
						<i style="font-size: 22px;" class="iconfont text-gold icon-qh-cart" id="shooping_cart_icon">&#xe61b;</i>
						<div class="text-gold">购物车</div>
						<span class="badge badge-important" id="shooping_cart_icon_number"></span>
					</a>
				</div>
			</div>
		</div>
	</div>
	<!-- END FOOTER -->

	<!-- BEGIN levitation button -->
	<!-- /btn-group -->
	<div class="btn-group btn-group-vertical dropup right_bottom_levitation_div">

		<button type="button" class="btn btn-lg dropdown-toggle shotcut-gray" data-toggle="dropdown" style="padding: 8px; border-radius: 5px !important;">
			<!-- <i class="fa fa-ellipsis-h"></i> -->
			<i style="font-size: 22px;" class="iconfont icon-qh-more">&#xe61e;</i>
		</button>
		<ul class="dropdown-menu pull-right padding-top-5 padding-bottom-2" role="menu">
			<li>
				<a href="./">
					<!-- <i class="fa fa-home text-gold"></i> -->
					<i style="font-size: 18px;" class="iconfont icon-qh-home text-gold">&#xe61a;</i> 店铺首页
				</a>
			</li>
			<li class="divider" style="width: 80%; margin: 2px auto;"></li>
			<li>
				<a href="goods_type/get_shop_goods_type">
					<!-- <i class="fa fa-search text-gold"></i> -->
					<i style="font-size: 18px;" class="iconfont icon-qh-search text-gold">&#xe62f;</i> 搜索
				</a>
			</li>
			<li class="divider" style="width: 80%; margin: 2px auto;"></li>
			<li>
				<a href="show_collection_list">
					<!-- <i class="fa fa-star-o text-gold"></i> -->
					<i style="font-size: 18px;" class="iconfont icon-qh-collect text-gold">&#xe61c;</i> 我的收藏
				</a>
			</li>
			<li class="divider" style="width: 80%; margin: 2px auto;"></li>
			<li>
				<a href="show_browser_history_list">
					<!-- <i class="fa fa-clock-o text-gold"></i> -->
					<i style="font-size: 18px;" class="iconfont icon-qh-history text-gold">&#xe630;</i> 最近浏览
				</a>
			</li>
		</ul>
		<button id="wx_kf" type="button" class="btn btn-lg shotcut-gray margin-top-5" style="padding: 8px; border-radius: 5px !important;">
			<i style="font-size: 22px;" class="iconfont icon-qh-kf">&#xe62c;</i>
		</button>
		<button id="click_to_top" type="button" class="btn btn-lg shotcut-gray margin-top-5" style="padding: 8px; border-radius: 5px !important;">
			<!-- <i class="fa fa-chevron-up"></i> -->
			<i style="font-size: 22px;" class="iconfont icon-qh-top">&#xe619;</i>
		</button>
	</div>
	<!-- /btn-group -->
	<!-- END levitation button -->

	<form action="confirm_order" method="post" style="display: none;" id="form_for_confirm_order">
		<input type="hidden" id="ids_for_confirm_order">
	</form>
	<input type="hidden" id="goods_id_input" value="${goods.goodsId }">
	<input type="hidden" id="buyer_id_input" value="${buyerSession.buyerId }">

	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->
	<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
	<script src="https://cdn.bootcss.com/jquery-migrate/1.2.1/jquery-migrate.min.js" type="text/javascript"></script>
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.0.8/js/swiper.jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery.lazyload.min.js"></script>
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<!-- END PAGE LEVEL SCRIPTS -->

	<script>
		$(function()
		{
			var swiper = new Swiper('.swiper-container',
			{
				pagination : '.swiper-pagination',
				slidesPerView : 'auto',
				centeredSlides : true,
				paginationClickable : true,
				lazyLoading : true,
				spaceBetween : 10
			});

			$(".lazy_load_img").lazyload(
			{
				placeholder : "images/default_light_goods_pic.jpg",
				effect : "fadeIn",
				threshold : 600
			});

			$("#go_to_goods_detail_div").click(function()
			{
				$("body,html").animate(
				{
					scrollTop : $("#goods_detail_big_div").offset().top + 1
				}, 500);
			});

			$("#go_to_post_message_div").click(function()
			{
				window.location.href = "post_message?id=${goods.goodsId }";
			});

			$("#click_to_top").click(function()
			{
				$('html,body').animate(
				{
					scrollTop : 0
				}, 'slow');
			});

			//商品购买数量加减
			$(".number_minus_button").click(function()
			{
				var inputId = $(this).attr("data-target");
				var inputObj = $(inputId);
				currentNum = parseInt(inputObj.val());
				var minnumber = inputObj.attr("data-minnumber");

				if (currentNum > minnumber)
				{
					inputObj.val(--currentNum);
				}
				else
				{
					inputObj.val(minnumber);
				}
			});
			$(".number_add_button").click(function()
			{
				var inputId = $(this).attr("data-target");
				var inputObj = $(inputId);
				currentNum = parseInt(inputObj.val());
				var maxnumber = inputObj.attr("data-maxnumber");

				if (currentNum < maxnumber)
				{
					inputObj.val(++currentNum);
				}
				else
				{
					inputObj.val(maxnumber);
					alert("最多能购买 " + maxnumber + " 件。");
				}
			});
			$(".buy_number_input").keyup(function()
			{
				var inputObj = $(this);
				currentNum = parseInt(inputObj.val());
				var minnumber = inputObj.attr("data-minnumber");
				var maxnumber = inputObj.attr("data-maxnumber");
				if (isNaN(currentNum))
				{
					inputObj.val(minnumber);
				}
				else
				{
					inputObj.val(currentNum);
					if (currentNum < minnumber)
					{
						inputObj.val(minnumber);
					}
					if (currentNum > maxnumber)
					{
						inputObj.val(maxnumber);
						alert("最多能购买 " + maxnumber + " 件。");
					}
				}
			});

			//添加购物车
			$(".add_to_shopping_cart_button").click(function()
			{

				var objButton = $(this);
				var goodsId = objButton.attr("data-id");
				var buy_number = $("#buy_number").val();
				$.post('${basePath}u_add_to_shoppingcar',
				{
					"cart.goodsId" : goodsId,
					"cart.goodsNumber" : buy_number
				}, function(json2)
				{
					if (json2.success == true)
					{
						var targetTd = $("#goods_gallery_swiper_div").find(".swiper-slide-active").find("img");
						var flyElm = targetTd.clone().css('opacity', '0.7');
						flyElm.css(
						{
							'z-index' : 9000,
							'display' : 'block',
							'position' : 'absolute',
							'top' : targetTd.offset().top + 'px',
							'left' : targetTd.offset().left + 'px',
							'width' : targetTd.width(),
							'height' : targetTd.height()
						});
						$('body').append(flyElm);
						flyElm.animate(
						{
							top : $('#shooping_cart_icon').offset().top,
							left : $('#shooping_cart_icon').offset().left,
							width : 16,
							height : 16,
						}, 'slow', function()
						{
							flyElm.remove();
							if (json2.numberchange > 0)
							{
								//$('#shooping_cart_icon').fadeOut(100).fadeIn(100);
								$("#shooping_cart_icon_number").fadeOut(100, function()
								{
									if (json2.numberchange < 100)
									{
										$("#shooping_cart_icon_number").html(json2.numberchange).fadeIn(100);
									}
									else
									{
										$("#shooping_cart_icon_number").html("99+").fadeIn(100);
									}
								});
							}
						});
					}
					else
					{
						alert(json2.info);
					}
				},
				//返回类型
				"json");
			});
			//立即购买
			$(".buy_right_now_button").click(function()
			{

				var objButton = $(this);
				var goodsId = objButton.attr("data-id");
				var buy_number = $("#buy_number").val();
				$.post('${basePath}u_add_to_shoppingcar',
				{
					"cart.goodsId" : goodsId,
					"cart.goodsNumber" : buy_number
				}, function(json2)
				{
					if (json2.success == true)
					{
						var targetTd = $("#goods_gallery_swiper_div").find(".swiper-slide-active").find("img");
						var flyElm = targetTd.clone().css('opacity', '0.7');
						flyElm.css(
						{
							'z-index' : 9000,
							'display' : 'block',
							'position' : 'absolute',
							'top' : targetTd.offset().top + 'px',
							'left' : targetTd.offset().left + 'px',
							'width' : targetTd.width(),
							'height' : targetTd.height()
						});
						$('body').append(flyElm);
						flyElm.animate(
						{
							top : $('#shooping_cart_icon').offset().top,
							left : $('#shooping_cart_icon').offset().left,
							width : 16,
							height : 16,
						}, 'slow', function()
						{
							flyElm.remove();
							if (json2.numberchange > 0)
							{
								//$('#shooping_cart_icon').fadeOut(100).fadeIn(100);
								$("#shooping_cart_icon_number").fadeOut(100, function()
								{
									if (json2.numberchange < 100)
									{
										$("#shooping_cart_icon_number").html(json2.numberchange).fadeIn(100, function()
										{
											window.location.href = "cart";
										});
									}
									else
									{
										$("#shooping_cart_icon_number").html("99+").fadeIn(100, function()
										{
											window.location.href = "cart";
										});
									}
								});
							}
						});
					}
					else
					{
						alert(json2.info);
					}
				},
				//返回类型
				"json");
			});

			//查看是否收藏了
			$.post('u_valid_goods_collection',
			{
				'id' : $("#goods_id_input").val()
			}, function(json)
			{
				if (json.success == true)
				{
					if (json.isCollected == false)
					{
						$("#buyer_collection_button_div").html('<a href="javascript:void(0)" class="icon-btn add_goods_collection">	<i class="fa fa-star-o text-gold"></i><div  class="text-gold">收藏</div></a>');
					}
					else
					{
						$("#buyer_collection_button_div").html('<a href="javascript:void(0)" class="icon-btn cancel_goods_collection"><i class="fa fa-star text-gold"></i><div  class="text-gold">已收藏</div></a>');
						$("#buyer_collection_button_div").attr("data-collection-id", json.collectionId);
					}
				}
			},
			//返回类型
			"json");

			//添加收藏
			$("#buyer_collection_button_div").on("click", ".add_goods_collection", function()
			{
				var obj = $(this);
				$.post('u_add_goods_collection_do',
				{
					'buyerCollection.primaryId' : $("#goods_id_input").val(),
					'buyerCollection.collectionType' : "商品"
				}, function(json)
				{
					if (json.success == true)
					{
						$("#buyer_collection_button_div").html('<a href="javascript:void(0)" class="icon-btn cancel_goods_collection"><i class="fa fa-star text-gold"></i><div  class="text-gold">已收藏</div></a>');
						$("#buyer_collection_button_div").attr("data-collection-id", json.collectionId);
					}
					else
					{
						alert(json.info);
					}
				},
				//返回类型
				"json");
			});

			//取消收藏
			$("#buyer_collection_button_div").on("click", ".cancel_goods_collection", function()
			{
				var obj = $(this);
				$.post('u_cancel_goods_collection_do',
				{
					'buyerCollection.collectionId' : $("#buyer_collection_button_div").attr("data-collection-id")
				}, function(json)
				{
					if (json.success == true)
					{
						$("#buyer_collection_button_div").html('<a href="javascript:void(0)" class="icon-btn add_goods_collection">	<i class="fa fa-star-o text-gold"></i><div  class="text-gold">收藏</div></a>');
						$("#buyer_collection_button_div").attr("data-collection-id", "");
					}
					else
					{
						alert(json.info);
					}
				},
				//返回类型
				"json");
			});

			//添加浏览历史记录
			if ($("#buyer_id_input").val().length > 0 && $("#goods_id_input").val().length > 0)
			{
				$.post('u_add_browser_history_do',
				{
					'browserHistory.goodsId' : $("#goods_id_input").val()
				}, function(json)
				{
					//静默添加浏览历史记录,添加成功与失败都不执行后续操作
				},
				//返回类型
				"json");
			}

			$.post("wc_get_wechat_info",
			{
				"currentUrl" : location.href.split('#')[0]
			}, function(json)
			{
				$("#test_div").html(json.appId + "," + json.timestamp + "," + json.nonceStr + "," + json.signature + "," + json.ticket + "," + json.currentUrl);
				wx.config(
				{
					debug : false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
					appId : json.appId, // 必填，公众号的唯一标识
					timestamp : json.timestamp, // 必填，生成签名的时间戳
					nonceStr : json.nonceStr, // 必填，生成签名的随机串
					signature : json.signature,// 必填，签名，见附录1
					jsApiList : [ 'onMenuShareTimeline', 'chooseWXPay', 'previewImage' ]
				// 必填，需要使用的JS接口列表，所有JS接口列表见附录2
				});
				wx.ready(function()
				{

					$("#goods_pic_div").find("img").each(function()
					{
						var obj = $(this);
						var urlsArray = new Array();
						$("#goods_pic_div").find("img").each(function(index, domEle)
						{
							urlsArray.push($(domEle).attr("data-real-src"));
						});

						obj.click(function()
						{
							wx.previewImage(
							{
								// 当前显示图片的http链接
								current : obj.attr("data-real-src"),
								// 需要预览的图片http链接列表
								urls : urlsArray
							});
						});
					});
					$("#goodsDetail_div").find("img").each(function()
					{
						var obj = $(this);
						var urlsArray = new Array();
						$("#goodsDetail_div").find("img").each(function(index, domEle)
						{
							urlsArray.push($(domEle).attr("data-original"));
						});

						obj.click(function()
						{
							wx.previewImage(
							{
								// 当前显示图片的http链接
								current : obj.attr("data-original"),
								// 需要预览的图片http链接列表
								urls : urlsArray
							});
						});
					});

					$("#wx_kf").click(function()
					{
						$.post("u_wx_create_customservice_do", {}, function(return_json)
						{
							if (return_json.success == true)
							{
								wx.closeWindow();
							}
						},
						//返回类型
						"json");
					});

				});
				wx.error(function(res)
				{
				});
				if ("${buyerSession.buyerId}".length <= 0)
				{
					var code = "${param.code}";
					if (code.length > 0)
					{
						$.post("wc_get_user_info",
						{
							'code' : code
						}, function(return_json)
						{
							if (return_json.success == true)
							{
								//alert("openid(getUserInfo):" + return_json.openid);
							}
						},
						//返回类型
						"json");
					}
					else
					{
						$.post("wc_valid_have_this_person", {}, function(valid_json)
						{
							if (valid_json.success == false)
							{

								var authUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect";

								authUrl = authUrl.replace("APPID", json.appId);
								authUrl = authUrl.replace("REDIRECT_URI", location.href.split('#')[0]);
								authUrl = authUrl.replace("SCOPE", "snsapi_base");
								authUrl = authUrl.replace("STATE", 1);
								window.location.href = authUrl;
							}
							else
							{
								//alert("openid(validHaveThisPerson):" + valid_json.openid);
							}
						},
						//返回类型
						"json");
					}
				}

			},
			//返回类型
			"json");

			String.prototype.startWith = function(str)
			{
				var reg = new RegExp("^" + str);
				return reg.test(this);
			}

			String.prototype.endWith = function(str)
			{
				var reg = new RegExp(str + "$");
				return reg.test(this);
			}

			//设置购物车购物数量
			if ($("#shooping_cart_icon_number").length > 0)
			{
				$.post('u_get_shoppingcar_number', {}, function(json)
				{
					if (json.success == true)
					{
						$("#shooping_cart_icon_number").fadeOut(100, function()
						{
							if (json.numberchange < 100)
							{
								$("#shooping_cart_icon_number").html(json.numberchange).fadeIn(100);
							}
							else
							{
								$("#shooping_cart_icon_number").html("99+").fadeIn(100);
							}
						});
					}
				},
				//返回类型
				"json");
			}
		});
	</script>
	<!-- END JAVASCRIPTS -->
</body>
</html>